package main

import (
	"fmt"
	// "time"
	"sync"
)

var wg sync.WaitGroup

//输出数字
func printNum(){
	defer wg.Done()
	for i := 1;i <=10;i++{
		fmt.Println(i)
	}
}
//做除法操作
func devide(){
	defer func(){
		err := recover()
		if err != nil{
			fmt.Println("devide出错，错误：",err)
		}
	}()

	defer wg.Done()
	num1 := 10
	num2 := 0
	result := num1 / num2
	fmt.Println(result)
}

func main(){
	wg.Add(2)
	//启动两个协程：
	go printNum()
	go devide()
	wg.Wait()
}